package com.xyh.concurrency.example.sync;

import com.xyh.concurrency.annoations.Recommend;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Recommend
public class SynchroizedExample {
    /**
     * 同步代码块
     */
    public void test() {
        synchronized (this) {
            for (int i = 0; i < 10; i++) {
                log.info("test -{}", i);
            }
        }
    }

    /**
     * 同步方法从
     */
    public synchronized void test1() {
        for (int i = 0; i < 10; i++) {
            log.info("test -{}", i);
        }
    }
}
